<template>
  <div class="carbon-platform">
    <nav class="navbar sticky-top bg-white shadow-sm py-3">
      <div class="container">
        <div class="d-flex justify-content-between align-items-center w-100">
          <!-- 网站标志 -->
          <div class="navbar-logo">
            <span class="logo-icon">🌱</span>
            <span class="logo-text">绿碳平台</span>
          </div>

          <!-- 中间导航链接 - 桌面版 -->
          <ul class="navbar-nav list-unstyled d-flex flex-row gap-3 gap-lg-5 justify-content-center flex-wrap align-items-center mb-0 fw-bold flex-grow-1 mx-4">
            <li class="nav-item">
              <a href="/index" class="nav-link text-dark hover:text-primary transition-colors">首页</a>
            </li>
            <li class="nav-item">
              <a href="/shop" class="nav-link text-dark hover:text-primary transition-colors">碳积分市场</a>
            </li>
            <li class="nav-item">
              <a href="/blog" class="nav-link text-dark hover:text-primary transition-colors">博客</a>
            </li>
            <li class="nav-item">
              <a href="/contact" class="nav-link text-dark hover:text-primary transition-colors">联系我们</a>
            </li>
            <li class="nav-item">
              <a href="/about" class="nav-link text-dark hover:text-primary transition-colors">关于我们</a>
            </li>
            <li class="nav-item">
              <a href="/order" class="nav-link text-dark hover:text-primary transition-colors">我的订单</a>
            </li>
          </ul>

          <!-- 右侧功能区 - 使用emoji图标 -->
          <div class="d-flex align-items-center gap-4 gap-lg-5">
            <!-- 搜索按钮 -->
            <button class="btn p-2 text-dark hover:text-primary transition-colors" aria-label="搜索">
              <span class="fs-5">🔍</span>
            </button>

            <!-- 购物车 -->
            <a href="/cart" class="btn p-2 text-dark hover:text-primary transition-colors position-relative" aria-label="购物车">
              <span class="fs-5">🛒</span>
<!--              <span class="position-absolute top-0 right-0 btn-success text-white text-xs rounded-full h-5 w-5 flex items-center justify-center" style="border-radius: 50%;">3</span>-->
            </a>

            <!-- 用户菜单 -->
            <div class="dropdown">
              <button class="btn p-2 text-dark hover:text-primary transition-colors" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="用户菜单">
                <span class="fs-5">👤</span>
              </button>
              <ul class="dropdown-menu dropdown-menu-end">
                <li><a class="dropdown-item" href="/login">登录</a></li>
                <li><a class="dropdown-item" href="/register">注册</a></li>
                <li><a class="dropdown-item" href="/account">我的账户</a></li>
              </ul>
            </div>

            <!-- 移动端菜单按钮 -->
            <button class="btn d-lg-none p-2 text-dark" type="button" data-bs-toggle="offcanvas" data-bs-target="#mobileMenu" aria-label="菜单">
              <span class="fs-5">☰</span>
            </button>
          </div>
        </div>
      </div>
    </nav>

    <!-- 顶部横幅 -->
    <div class="banner-section contact-banner">
      <div class="container">
        <div class="banner-content">
          <nav aria-label="面包屑导航">
          </nav>
          <h1 class="banner-title">联系我们</h1>
        </div>
      </div>
    </div>

    <!-- 主内容区域 -->
    <main class="contact-page py-5">
      <div class="container-lg">
        <div class="row g-5">
          <!-- 左侧联系方式 -->
          <div class="col-lg-5">
            <div class="card shadow-sm h-100">
              <div class="card-body">
                <h3 class="mb-4">联系方式</h3>
                <!-- 办公信息 -->
                <div class="contact-info mb-5">
                  <h5 class="title-with-line">办公信息</h5>
                  <div class="info-item">
                    <i class="bi bi-geo-alt"></i>
                    <span>730 Glenstone Ave 65802, Springfield, US</span>
                  </div>
                  <div class="info-item">
                    <i class="bi bi-telephone"></i>
                    <div>
                      <p>+123 987 321</p>
                      <p>+123 123 654</p>
                    </div>
                  </div>
                  <div class="info-item">
                    <i class="bi bi-envelope"></i>
                    <span>contact@website.com</span>
                  </div>
                </div>

                <!-- 管理信息 -->
                <div class="contact-info">
                  <h5 class="title-with-line">管理信息</h5>
                  <div class="info-item">
                    <i class="bi bi-geo-alt"></i>
                    <span>730 Glenstone Ave 65802, Springfield, US</span>
                  </div>
                  <div class="info-item">
                    <i class="bi bi-telephone"></i>
                    <div>
                      <p>+123 987 321</p>
                      <p>+123 123 654</p>
                    </div>
                  </div>
                  <div class="info-item">
                    <i class="bi bi-envelope"></i>
                    <span>contact@website.com</span>
                  </div>
                </div>

                <!-- 社交媒体 -->
                <div class="social-media mt-5">
                  <a href="#" class="social-icon"><i class="bi bi-facebook"></i></a>
                  <a href="#" class="social-icon"><i class="bi bi-twitter"></i></a>
                  <a href="#" class="social-icon"><i class="bi bi-instagram"></i></a>
                  <a href="#" class="social-icon"><i class="bi bi-linkedin"></i></a>
                </div>
              </div>
            </div>
          </div>

          <!-- 右侧留言表单 -->
          <div class="col-lg-7">
            <div class="card shadow-sm">
              <div class="card-body">
                <h3 class="mb-4">留言咨询</h3>
                <p class="text-muted mb-4">请填写下方表单联系我们，我们将在24小时内回复您</p>

                <form @submit.prevent="submitForm">
                  <div class="row g-3">
                    <div class="col-md-6">
                      <label class="form-label">您的姓名</label>
                      <input type="text" class="form-control" placeholder="请输入姓名" v-model="form.name" required>
                    </div>
                    <div class="col-md-6">
                      <label class="form-label">电子邮箱</label>
                      <input type="email" class="form-control" placeholder="请输入邮箱" v-model="form.email" required>
                    </div>
                    <div class="col-12">
                      <label class="form-label">联系电话</label>
                      <input type="tel" class="form-control" placeholder="请输入电话" v-model="form.phone">
                    </div>
                    <div class="col-12">
                      <label class="form-label">主题</label>
                      <input type="text" class="form-control" placeholder="请输入主题" v-model="form.subject" required>
                    </div>
                    <div class="col-12">
                      <label class="form-label">留言内容</label>
                      <textarea class="form-control" rows="5" placeholder="请输入留言内容" v-model="form.message" required></textarea>
                    </div>
                    <div class="col-12">
                      <button type="submit" class="btn btn-success btn-lg">提交留言</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>

        <!-- 百度地图 -->
        <div class="map-container mt-5">
          <div id="baidu-map" style="height: 400px; width: 100%;"></div>
        </div>
      </div>
    </main>

    <!-- 相关推荐部分 -->
    <section class="related-searches py-5 bg-light">
      <div class="container-lg">
        <h2 class="section-title mb-4">大家都在搜</h2>
        <div class="d-flex flex-wrap gap-2 mb-5">
          <a href="#" class="fs-6 badge bg-white text-dark border px-3 py-2 text-decoration-none"
             v-for="item in relatedSearches" :key="item"
             @click.prevent="searchItem(item)">
            {{ item }}
          </a>
        </div>
      </div>
    </section>

    <!-- 页脚部分 -->
    <footer class="main-footer">
      <div class="container">
        <div class="footer-bottom">
          <p class="copyright">© 2025 绿碳平台 版权所有 | 京ICP备12345678号</p>
        </div>
      </div>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'Contact',
  data() {
    return {
      cartItems:[],
      isLoading: false,
      form: {
        name: '',
        email: '',
        phone: '',
        subject: '',
        message: ''
      },
      relatedSearches: [
        '碳达峰', '碳足迹', '绿电', '碳交易', '碳抵消',
        '可再生能源', '低碳生活', '碳核算', 'ESG', '气候金融','碳积分',
        '绿色发电','绿色金融','环保'
      ],
    }
  },
  mounted() {
    this.initBaiduMap()
  },
  methods: {
    initBaiduMap() {
      // 百度地图API功能
      window.onload = function() {
        // 替换为您的百度地图API密钥
        const AK = '0yxgFNNIHkf9DDTRrq9LlJzWCMEZ0uFe'
        const script = document.createElement('script')
        script.src = `https://api.map.baidu.com/api?v=3.0&ak=${AK}&callback=initMap`
        document.head.appendChild(script)
      }

      // 全局回调函数
      window.initMap = () => {
        const map = new BMap.Map('baidu-map')

        // 云南大学呈贡校区坐标（经度102.8486, 纬度24.8235）
        const point = new BMap.Point(102.8486, 24.8235)
        map.centerAndZoom(point, 17) // 17级缩放显示校园细节

        // 添加地图控件
        map.addControl(new BMap.NavigationControl())
        map.addControl(new BMap.ScaleControl())
        map.addControl(new BMap.OverviewMapControl())
        map.enableScrollWheelZoom()

        // 添加标记
        const marker = new BMap.Marker(point)
        map.addOverlay(marker)

        // 信息窗口
        const infoWindow = new BMap.InfoWindow('我们的办公地址')
        marker.addEventListener('click', () => {
          marker.openInfoWindow(infoWindow)
        })
      }
    },
    submitForm() {
      // 表单提交逻辑
      alert('留言提交成功！我们会尽快与您联系')
      this.form = {
        name: '',
        email: '',
        phone: '',
        subject: '',
        message: ''
      }
    }
  }
}
</script>

<style scoped>
.organic-store {
  font-family: 'Nunito', sans-serif;
}

.banner-section {
  background-image: url('../../public/images/banner-1.jpg');
  background-size: cover;
  background-position: center;
  height: 300px;
  display: flex;
  align-items: center;
  position: relative;
}

.banner-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.2);
}

.banner-content {
  position: relative;
  z-index: 1;
  color: #fff;
  padding: 20px;
}

.breadcrumb {
  background-color: transparent;
  padding: 0;
  margin-bottom: 15px;
}

.breadcrumb-item {
  color: #fff;
}

.breadcrumb-item.active {
  color: rgba(255, 255, 255, 0.8);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: rgba(255, 255, 255, 0.8);
}

.banner-title {
  font-size: 3rem;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin: 0;
}

@media (max-width: 768px) {
  .banner-section {
    height: 200px;
  }

  .banner-title {
    font-size: 2rem;
  }
}

.contact-info {
  margin-bottom: 2rem;
}

.title-with-line {
  position: relative;
  padding-bottom: 10px;
  margin-bottom: 20px;
}

.title-with-line::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 50px;
  height: 3px;
  background: #28a745;
}

.info-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 15px;
}

.info-item i {
  font-size: 1.2rem;
  color: #28a745;
  margin-right: 15px;
  margin-top: 3px;
}

.social-media {
  display: flex;
  gap: 15px;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #f8f9fa;
  border-radius: 50%;
  color: #28a745;
  font-size: 1.2rem;
  transition: all 0.3s;
}

.social-icon:hover {
  background: #28a745;
  color: white;
  transform: translateY(-3px);
}

.map-container {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
</style>